import { FormItemType } from "@/components/CustomForm/utils/types";
import { CTableColumnProps, TableStyleInt } from "./types";
import * as _ from "lodash";
import { FormItemEnum } from "@/components/CustomForm/utils/enums";

/**
 *  表格默认样式
 */
export const defaultStyle: TableStyleInt = {
  borderCell: true,
  stripe: true,
  size: "default",
};

/**
 * 设置默认属性
 * @param columns
 * @returns
 */
export const setDefaultProps = (columns: CTableColumnProps[]) => {
  const _columns = _.cloneDeep(columns);
  return _columns.map((el) => {
    return {
      ...el,
      width: el.width ?? 100,
    };
  });
};

/**
 * 表格设置样式表单配置
 */
export const setFormItems: FormItemType[] = [
  {
    field: "stripe",
    label: "斑马纹",
    el: FormItemEnum.SWITCH,
  },
  {
    field: "size",
    label: "表格尺寸",
    el: FormItemEnum.RADIO,
    enum: [
      {
        label: "默认",
        value: "default",
      },
      {
        label: "中",
        value: "middle",
      },
      {
        label: "小",
        value: "small",
      },
      {
        label: "迷你",
        value: "mini",
      },
    ],
  },
  {
    field: "borderCell",
    label: "表格边框",
    el: FormItemEnum.SWITCH,
  },
];
